<?php
class SellersController extends AppController {
    public $helpers = array('Html', 'Form', 'Session', 'Permission');
    public $components = array('Session');
    public $uses = array('Seller');
    
    public function index() {
        $this->set('sellers', $this->Seller->find('all'));
    }

    function descargar($id = null)
    	{
    	if (!$id)
    		{
    			$this->Session->setFlash('no has seleccionado ningun pdf.');
    			$this->redirect(array('action'=>'index'));
    		}
    		// Sobrescribimos para que no aparezcan los resultados de debuggin
    		// ya que sino daria un error al generar el pdf.
    		Configure::write('debug',0);
    		$resultado = $this->Seller->findById($id);
    		$this->set("datos_pdf",$resultado);
    		$this->layout = 'pdf'; //esto usara el layout pdf.ctp
    		$this->render();
    }
    
    
    public function edit($id = null) {
    	$this->Seller->id = $id;
    	if ($this->request->is('get')) {
    		$this->request->data = $this->Seller->read();
    	} else {
    		if ($this->Seller->save($this->request->data)) {
    			$this->Session->setFlash('Your post has been updated.');
    			$this->redirect(array('action' => 'index'));
    		} else {
    			$this->Session->setFlash('Unable to update your post.');
    		}
    	}
    }
    
    public function add() {  
    	if ($this->request->is('post')) {
            $this->Seller->create();
            if ($this->Seller->save($this->request->data)) {
                $this->Session->setFlash('Your post has been saved.');
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash('Unable to add your post.');
            }
        }
    }
    public function delete($id) {
    	//if ($this->request->is('get')) {
    	//	throw new MethodNotAllowedException();
    	//}
    	$this->Seller->id = $id;
    	$this->set('seller', $this->Seller->delete($id));
    	$this->redirect(array('action' => 'index'));
    	if ($this->Seller->delete($id)) {
    		$this->Session->setFlash('The seller with id: ' . $id . ' has been deleted.');
    		$this->redirect(array('action' => 'index'));
    	}
    }
    public function view($id) {
    	$this->Seller->id = $id;
    	$this->set('seller', $this->Seller->read());    
    }
    
    public function beforeFilter() {
    	parent::beforeFilter();
    	//$this->Auth->allow('index', 'view');
    }
}
?>









